package com.xizi.秋招笔试.bilibili;

import java.util.Scanner;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-8-25下午 07:25
 */
public class A {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[][] ans = new int[300][300];
        int index = 0;
        int n = 0;
        while (scanner.hasNextLine()) {
            String[] split = scanner.nextLine().split(",");
            if (split.length == 0) break;
            for (int i = 0; i < split.length; i++) {
                ans[index][i] = Integer.parseInt(split[i]);
            }
            index++;
        }
        scanner.close();
        for (int i = 0; i < ans[0].length; i++) {
            if (ans[0][i] == 0) {
                continue;
            }
            boolean f = true;
            int temp = ans[0][i];
            for (int j = 1; j < ans.length; j++) {
                int l = 0, r = ans[j].length - 1;
                while (l < r) {
                    int mid = l + r + 1 >> 1;
                    if (ans[j][mid] <= temp) l = mid;
                    else r = mid - 1;
                }
                if (ans[j][l] != temp) {
                    f = false;
                    break;
                }
            }
            if (f) {
                System.out.println(temp);
                break;
            }
        }
    }
}
